package com.sample.snl.frontend.LexicalAnalysis;

import java.io.IOException;

public class InCharState extends State {

    Automaton automaton;

    public InCharState(Automaton a) {
        this.automaton = a;
    }

    @Override
    void HandleCharacter(int ch) throws IOException {
        if (automaton.isAlphabetic(ch) || automaton.isDigit(ch)) {
            ch = automaton.getChar();
            if (ch == '\'') {
                automaton.token = new Token(LexicalAnalyser.line, LexicalAnalyser.column, TokenType.CHARACTER, automaton.stringBuilder.toString());
                //LexicalAnalyser.LOG.debug("Recognized Token:" + automaton.token);
                automaton.gotToken = true;
                return;
            }
        }
        automaton.setState(automaton.ErrorState);
    }
}
